using System.Linq;
using Microsoft.Practices.Unity;

namespace Framework.Testing
{
    public static class UnityContainerExtensions
    {
        public static ContainerRegistration GetRegistration<T, TManager>(this IUnityContainer container)
        {
            var registration = container.Registrations.FirstOrDefault(
                r => typeof(T).IsAssignableFrom(r.RegisteredType) &&
                     r.LifetimeManagerType == typeof(TManager));
            return registration;
        }
    }
}